package com.example.demo.lc;

import java.util.HashSet;
import java.util.Set;

/**
 * @Description TODO
 * @Author wzh
 * @Date 2021/11/10 3:35 下午
 * @Version 1.0
 */
public class Leetcode1079 {
    public static void main(String[] args) {
        //System.out.println(numTilePossibilities("aab"));
        System.out.println(numTilePossibilities("V"));
    }

    static Set<String> set = new HashSet<>();
    static int total = 0;

    public static int numTilePossibilities(String tiles) {
        boolean[] visited = new boolean[tiles.length()];
        String str = "";
        dfs(tiles, visited, str);
        return total;
    }

    private static void dfs(String tiles, boolean[] visited, String str) {
        for (int i = 0; i < tiles.length(); i++) {
            if (!str.equals("") && !set.contains(str)) {
                System.out.println("----"+str);
                set.add(str);
                total++;
            }
        }
        for (int i = 0; i < tiles.length(); i++) {
            if (!visited[i]) {
                visited[i] = true;
                dfs(tiles, visited, str + tiles.charAt(i));
                visited[i] = false;
            }
        }
    }


}
